<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .fa{
            width: 400px;
            margin-bottom: 30px;
            border: 1px solid red;;
        }
        .son{
            width: 0px;
            height: 40px;
            background-color: #f0f;
            text-align: center;
            line-height: 40px;
        }
    </style>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
</head>
<body>
    <div class="fa">
        <div class="son">
            <span>0</span><span>%</span>
        </div>
    </div>
    <button id="but">安装</button>
    
    <script>
		let timer = null;
		$('#but').click( function() {
			if(timer == null){
				let num = 0;
				timer = setInterval( () =>{
					num += 1;
					$('div').eq(1).css('width', num + 'px');
					$('span').eq(0).text(Math.ceil(num / 4));
					if(num === 400){
						clearInterval(timer);
					}
				}, 10);
			}
		});


    </script>
</body>
</html>